<%--
  Created by IntelliJ IDEA.
  User: 林
  Date: 2022-01-04
  Time: 15:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>生产调度</title>
</head>
<style>
    .modal-content {
        width: 1000px;
        position: relative;
        left: -230px;
    }
    .form-control {
        border-bottom: 1px solid;
        border-top: 0px;
        border-left: 0px;
        border-left: 0px;
        display: block;
        width: 100%;
        height: 34px;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.42857143;
        color: #555;
        /* background-color: #fff; */
        /* background-image: none; */
        /* border: 1px solid #ccc; */
        border-radius: 4px;
        /* -webkit-box-shadow: inset 0 1px 1px rgb(0 0 0 / 8%); */
        /* box-shadow: inset 0 1px 1px rgb(0 0 0 / 8%); */
        /* -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s; */
        -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        /* transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; */
    }
</style>
<body>
<div class="container">
    <div id="toolbar">
        <form class="form form-inline">            <div class="form-group">
                <label for="productName" class="control-label">计划单编号</label>
                <input type="text" id="productName" class="form-control">
            </div>
            <input type="button" class="btn btn-success" value="查询" id="btcselect">
        </form>
    </div>
</div>
<table id="tableqwq">

</table>
<div class="modal fade" id="edituserwin">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">确认派工单</h4>
            </div>
            <div class="modal-body">
                <form class="form form-horizontal">
                    <div class="form-group">
                        <label for="did" class="col-md-2 text-right control-label">计划单编号</label>
                        <div class="col-md-10">
                            <input class="form-control" readonly type="text" name="did" id="did" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="dname" class="col-md-2 text-right control-label">产品单编号</label>
                        <div class="col-md-10">
                            <input class="form-control" readonly type="text" name="dname" id="dname" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="duser" class="col-md-2 text-right control-label">产品名称</label>
                        <div class="col-md-10">
                            <input class="form-control" readonly type="text" name="duser" id="duser" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="dpwd" class="col-md-2 text-right control-label">描述</label>
                        <div class="col-md-10">
                            <input class="form-control" readonly type="text" name="dpwd" id="dpwd" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="ddpet" class="col-md-2 text-right control-label">数量</label>
                        <div class="col-md-10">
                            <input class="form-control" readonly type="text" name="ddpet" id="ddpet" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="dpost" class="col-md-2 text-right control-label">出库单编号集合</label>
                        <div class="col-md-10">
                            <input class="form-control" readonly type="text" name="dpost" id="dpost" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="dhaed" class="col-md-2 text-right control-label">审核时间</label>
                        <div class="col-md-10">
                            <input class="form-control" readonly type="text" name="dhaed" id="dhaed" />
                        </div>
                    </div>
                </form>
                <div class="modal-footer">
                    <input type="button" class="btn btn-success" onclick='Dispatch()' value="派工">
                    <input type="button" class="btn btn-warning" data-dismiss="modal" value="关闭">
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var params={
        url:"${pageContext.request.contextPath}/psmanage.action",
        method: 'GET',                      //请求方式（*）
        toolbar: '#toolbar',              //工具按钮用哪个容器
        striped: true,                      //是否显示行间隔色
        cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true,                   //是否显示分页（*）
        sortable: true,                     //是否启用排序
        sortOrder: "asc",                   //排序方式
        sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1,                      //初始化加载第一页，默认第一页,并记录
        pageSize: 5,                     //每页的记录行数（*）
        pageList: [5, 10, 25, 50, 100],        //可供选择的每页的行数（*）
        search: false,                      //是否显示表格搜索
        strictSearch: true,
        showColumns: true,                  //是否显示所有的列（选择显示的列）
        showRefresh: true,                  //是否显示刷新按钮
        minimumCountColumns: 2,             //最少允许的列数
        clickToSelect: true,                //是否启用点击选中行
        height: 500,                      //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
        uniqueId: "id",                     //每一行的唯一标识，一般为主键列
        showToggle: true,                   //是否显示详细视图和列表视图的切换按钮
        cardView: false,                    //是否显示详细视图
        detailView: false,                  //是否显示父子表
        queryParams: function (params) {
            //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            var temp = {
                pagesize: params.limit,                         //页面大小
                pageno: (params.offset / params.limit) + 1,   //页码
                productName: $("#productName").val()  //查询条件
            };
            return temp;
        },
        columns:[
            {
                title:"计划单编号",
                field:"applyId"
            },
            {
                title:"产品单编号",
                field:"productId"
            },
            {
                title:"产品名称",
                field:"productName"
            },
            {
                title:"描述",
                field:"productDescribe",
                formatter:function (value){
                    if(value==null){
                        return "暂无数据"
                    }
                }
            },
            {
                title:"数量",
                field:"amount"
            },
            {
                title:"出库单编号集合",
                field:"spayList",
                formatter:function (value){
                    return value.payId;
                }
            },
            {
                title:"审核时间",
                field:"checkTime"
            },

            {
                title:"操作",
                field: "",
                formatter:function (value, row, index) {
                    return "<input type='button' value='打印' class='btn btn-success' onclick='dy("+row.applyId+")'>"+"&nbsp;";
                }
            }
    ]};
    $("#tableqwq").bootstrapTable(params)
    $("#btcselect").click(function () {
        //刷新表格数据
        $("#tableqwq").bootstrapTable("refresh");
    })
    function dy(applyId) {
        $.ajax({
            url:'psmanage.action/'+applyId+'',
            type: "get",
            dataType: "json",
            success:function (data){
                $("#did").val(data.applyId)
                $("#dname").val(data.productId)
                $("#duser").val(data.productName)
                $("#dpwd").val(data.productDescribe)
                $("#ddpet").val(data.amount)
                $("#dpost").val(data.payId)
                $("#dhaed").val(data.checkTime)
            }
        })
        $("#edituserwin").modal("show");
    }
    function Dispatch(){
     var id=$("#did").val()
        if (confirm("确定派工吗")){
            $.ajax({
                url:'${pageContext.request.contextPath}/pasmanage.action/'+id,
                type: "put",
                dataType: "json",
                success:function (data){
                    alert("派工成功等待审核")
                    $("#edituserwin").modal("hide");
                    $("#tableqwq").bootstrapTable("refresh");
                },
                error:function (data){
                    alert("ERROR")
                }
            })
        }
    }
</script>
</body>
</html>
